<?php

namespace Wonfu\Http;

use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\StreamInterface;
use Psr\Http\Message\UriInterface;
use Symfony\Component\HttpFoundation\Request;

class ServerRequest extends Request implements ServerRequestInterface
{

    /**
     * 唯一请求号
     * @var string
     */
    private $_uniqReqNo = '';

    protected $controller;
    protected $action;

    protected $psrRequest;

    /**
     * @return mixed
     */
    public function getController()
    {
        return $this->controller;
    }

    /**
     * @param mixed $controller
     */
    public function setController($controller): void
    {
        $this->controller = $controller;
    }

    /**
     * @return mixed
     */
    public function getAction()
    {
        return $this->action;
    }

    /**
     * @param mixed $action
     */
    public function setAction($action): void
    {
        $this->action = $action;
    }


    /**
     * @return string
     */
    public function getUniqReqNo(): string
    {
        return $this->_uniqReqNo;
    }

    /**
     * @param string $uniqReqNo
     */
    public function setUniqReqNo(string $uniqReqNo): void
    {
        $this->_uniqReqNo = $uniqReqNo;
    }


    /**
     * 检索消息的请求目标。
     *
     * 如果没有可用的URI，并且没有明确的请求目标
     * 如果提供，此方法必须返回字符串“/”。
     * @return string|void
     */
    public function getRequestTarget()
    {
        return $this->getPathInfo();
    }

    /**
     * 返回具有特定请求目标的实例。
     *
     *   该方法的实施方式必须保留
     *   消息的不变性，并且必须返回具有
     *   更改了请求目标。
     * @param mixed $requestTarget
     */
    public function withRequestTarget($requestTarget)
    {
        return $this->psrRequest->withRequestTarget($requestTarget);
    }

    /**
     * 返回1个提供了http方法的请求示例
     * @param string $method
     * @return void|ServerRequest
     */
    public function withMethod($method)
    {
        // TODO: Implement withMethod() method.
    }


    public function withUri(UriInterface $uri, $preserveHost = false)
    {
        // TODO: Implement withUri() method.
    }

    public function getServerParams()
    {
        // TODO: Implement getServerParams() method.
    }

    public function getCookieParams()
    {
        // TODO: Implement getCookieParams() method.
    }

    public function withCookieParams(array $cookies)
    {
        // TODO: Implement withCookieParams() method.
    }

    public function getQueryParams()
    {
        return $this->query->all();
    }

    public function withQueryParams(array $query)
    {
        // TODO: Implement withQueryParams() method.
    }

    /**
     * 检索规范化的文件上传数据。
     * @return array|void
     */
    public function getUploadedFiles()
    {
        // TODO: Implement getUploadedFiles() method.
        return $this->files->all();
    }

    /**
     *
     * @param array $uploadedFiles
     * @return void|ServerRequest
     */
    public function withUploadedFiles(array $uploadedFiles)
    {
        // TODO: Implement withUploadedFiles() method.
    }

    public function getParsedBody()
    {
        // TODO: Implement getParsedBody() method.
    }

    public function withParsedBody($data)
    {
        // TODO: Implement withParsedBody() method.
    }

    public function getAttributes()
    {
        // TODO: Implement getAttributes() method.
    }

    public function getAttribute($name, $default = null)
    {
        // TODO: Implement getAttribute() method.
    }

    public function withAttribute($name, $value)
    {
        // TODO: Implement withAttribute() method.
    }

    public function withoutAttribute($name)
    {
        // TODO: Implement withoutAttribute() method.
    }

    public function getProtocolVersion()
    {
        // TODO: Implement getProtocolVersion() method.
    }

    public function withProtocolVersion($version)
    {
        // TODO: Implement withProtocolVersion() method.
    }

    public function getHeaders()
    {
        // TODO: Implement getHeaders() method.
    }

    public function hasHeader($name)
    {
        // TODO: Implement hasHeader() method.
    }

    public function getHeader($name)
    {
        // TODO: Implement getHeader() method.
    }

    public function getHeaderLine($name)
    {
        // TODO: Implement getHeaderLine() method.
    }


    /**
     * 设置大小写不敏感的header信息
     * @param string $name
     * @param string|string[] $value
     * @return void|ServerRequest
     */
    public function withHeader($name, $value)
    {
        $this->headers->set($name, $value);
        return $this;
    }

    /**
     * Headers with multiple values
     * <code>
     *   <?php
     *      $message = $message
     *       ->withHeader('foo', 'bar')
     *       ->withAddedHeader('foo', 'baz');
     *
     *       $header = $message->getHeaderLine('foo');
     *      // $header contains: 'bar,baz'
     *
     *      $header = $message->getHeader('foo');
     *      // ['bar', 'baz']
     *    ?>
     * </code>
     * @param string $name
     * @param string|string[] $value
     * @return void|ServerRequest
     */
    public function withAddedHeader($name, $value)
    {
        // TODO: Implement withAddedHeader() method.
    }

    public function withoutHeader($name)
    {
        // TODO: Implement withoutHeader() method.
    }

    public function getBody()
    {
        // TODO: Implement getBody() method.
    }

    public function withBody(StreamInterface $body)
    {
        // TODO: Implement withBody() method.
    }


}